<template>
	<view class="content">
		<door-navbar></door-navbar>
		<u-cell-group :border="false" :customStyle="{
			background:'#fff',padding:'0 40rpx'}">
			<u-cell v-for="(item,index) in cellList" :key="`item_${index}`" :icon="item.icon"
				:iconStyle="{color:'#333',width:'42rpx',height:'32rpx',marginRight:'20rpx'}" :title="item.name"
				:titleStyle="{color:'#333333',fontSize:'28rpx'}" :border="index != cellList.length - 1?true:false"
				:rightIconStyle="{color:'#333',width:'12rpx',height:'12rpx'}" :isLink="item.url?true:false"
				:url="item.url?item.url:''" @click="clickTap(item)">
				<template slot="right-icon">
					<u-icon style="margin-left: 20rpx;" size="24" name="arrow-right" color="#333">
					</u-icon>
				</template>
			</u-cell>
		</u-cell-group>	
		<u-button class="big_btn" text="退出登录" @click="loginOut">
		</u-button>		
		<u-toast ref="uToast"></u-toast>
		<door-modal></door-modal>
	</view>
</template>

<script>	
	export default {
		components: {			
		},
		data() {
			return {
				cellList: [			
					{
						name: '修改个人信息',
						icon: '../../static/image/set_about.svg',
						url: '/pages/mine/userInfo'
					},					
				],
				userInfo: {},
				showRealName: false,
			};
		},
		async onLoad() {
			if (uni.getStorageSync('userInfo')) {
				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
			}else {
				this.userInfo = await this.$api.getUserInfo();
			}
		},
		methods: {
			async clickTap(e) {
				if (e.type) {
					this[e.type] = true;
				}
			},
			hide() {
				this.getUserInfo();
				this.showRealName = false;
			},
			async getUserInfo() {
				let phone = JSON.parse(uni.getStorageSync('userInfo')).phone
				let res = await this.$u.api.getUserInfo({
					phone: phone
				})
				this.userInfo = res.data;
				uni.setStorageSync('userInfo', JSON.stringify(res.data));
			},
			loginOut() {
				uni.clearStorageSync()
				uni.reLaunch({
					url: '/pages/login/login'
				})
			},
			showAbout() {
				this.$api.showModal({
					show: true,
					content: '关于我们',
					title: '关于我们',
					showCancelButton: false,
					success: res => {
						if (res.confirm) {
							console.log(res)
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 0;
		padding-top: 108rpx;
		background-color: #fff;
	}

	.big_btn {
		position: absolute;
		bottom: 100rpx;
		width: calc(100vw - 80rpx);
		margin-left: 40rpx;
		border: 2rpx solid $time-color-primary;
		height: 80rpx;
		font-size: 28rpx;
		color: $time-color-primary;
		height: 80rpx;
		border-radius: 20rpx;
	}

	/deep/ .u-cell__body {
		padding: 30rpx 0;
	}

	/deep/ .u-line {
		border-color: #eeeeee !important;
	}

	/deep/ .u-cell--clickable {
		background: transparent;
	}
</style>
